import 'package:flutter/material.dart';
import 'package:intro_slider/intro_slider.dart';
import 'package:intro_slider/slide_object.dart';
import 'package:kasax_demos2/commons/common_test_datas.dart';

/// https://pub.flutter-io.cn/packages/intro_slider
/// https://juejin.cn/post/6844903810972778510
/// Default config
/// 类报错，暂时放弃
class IntroSliderDemo extends StatefulWidget {
  const IntroSliderDemo({Key? key}) : super(key: key);

  @override
  _IntroSliderDemoState createState() => _IntroSliderDemoState();
}

class _IntroSliderDemoState extends State<IntroSliderDemo> {
  List<Slide> _slides = [];

  Widget circleAvatar(int index) {
    return CircleAvatar(
      radius: 100,
      backgroundImage: AssetImage(
        // "assets/images/${TestDatas.LOCAL_POSTER_IMGS[index]}",
        TestDatas.genRandomPosterImg(),
      ),
    );
  }

  @override
  void initState() {
    _slides.add(Slide(
        title: "ERASER",
        description:
            "Allow miles wound place the leave had. To sitting subject no improve studied limited",
        backgroundColor: Color(0xfff5a623),
        centerWidget: circleAvatar(0)));
    _slides.add(Slide(
        title: "PENCIL",
        description:
            "Ye indulgence unreserved connection alteration appearance",
        backgroundColor: Color(0xff203152),
        centerWidget: circleAvatar(1)));
    _slides.add(Slide(
        title: "RULER",
        description:
            "Much evil soon high in hope do view. Out may few northward believing attempted. Yet timed being songs marry one defer men our. Although finished blessing do of",
        backgroundColor: Color(0xff9932CC),
        centerWidget: circleAvatar(2)));

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: IntroSlider(
        onDonePress: () {},
        slides: _slides,
      ),
    );
  }
}
